<template>
  <div id="header">
    <button @click="goBack">&lt;</button>
    <span>{{title}}</span>
  </div>
</template>
<script>
import "./index.less";
import { middleVue } from "../../services";
import { remove } from "lodash";
export default {
  data() {
    return {
      popupComponents: {}
    };
  },
  methods: {
    goBack() {
      if (Object.keys(this.popupComponents).length > 0) {
        if (this.mintPopup) {
          this.popupComponents[this.mintPopup].close();
        }
        if (this.newsDetail) {
          this.popupComponents[this.newsDetail].close();
        }
      }
      if (this.isRoute) {
        this.$router.go(-1);
      }
    }
  },
  props: ["title", "mintPopup", "newsDetail", "isRoute"],
  created() {
    middleVue.$on("getPopupComponent", popupComponent => {
      this.popupComponents[Object.keys(popupComponent)[0]] =
        popupComponent[Object.keys(popupComponent)[0]];
    });
  },
  destroyed() {
    middleVue.$off("getPopupComponent");
  }
};
</script>